home *** CD-ROM | disk | FTP | other *** search
/ Programmer Power Tools / Programmer Power Tools.iso / microcrn / issue_46.arc / ISR.ARC / CALLER.H < prev    next >
Encoding:
C/C++ Source or Header  |  1988-05-11  |  1.5 KB  |  50 lines

  1. /*    CALLER.h -  header for the CALLER modules
  2.  
  3.         Supports ISR article in Micro Cornucopia Magazine Issue #46
  4. */
  5.  
  6.  
  7. #ifndef ISR_HDR_LOADED
  8. #include <isr.h>
  9. #endif
  10.  
  11.  
  12. /*    CPUREGS - Variables that are used as CPU register copies.
  13.  
  14.     The module "CALLER.C" contains the function caller(), and
  15.     a variable list which is in its code segment. 
  16.     Caller() loads the CPU registers with the vars,
  17.     does the call, then loads the vars with the CPU
  18.     registers. The way the vars are defined, their contents can
  19.     be accessed in a number of different ways; ergo the 
  20.     declarations below:
  21.  
  22.     The macros int86(), call86() & pcdos() also use caller().
  23. */
  24.  
  25. extern unsigned char far _AH, _AL, _BH, _BL, _CH, _CL, _DH, _DL;
  26. extern unsigned int  far _AX, _BX, _CX, _DX, _SI, _DI, _BP;
  27. extern unsigned long far _DXAX;
  28. extern unsigned char far * far _BPSI;
  29. extern unsigned char far * far _DSDX;
  30. extern unsigned char far * far _ESBX;
  31. extern unsigned int  far _DS, _ES;
  32. extern          void far (* far _PC)();
  33. extern unsigned int  far _IP, _CS, _PSW;
  34. extern unsigned char far * far _STKPTR;
  35. extern unsigned int  far _SP, _SS;
  36.  
  37. unsigned int far caller(void);
  38.  
  39. /* the following spaghetti is a work-around... */
  40. #define __xx1(i) (+(ulong)((i) * 4))
  41. #define __xx2(i) ((long far *)__xx1((i)))
  42. #define __xx3(i) (*__xx2((i)))
  43. #define isr_get_vec(inum) ((void far (*)())__xx3((ulong)(inum)))
  44.  
  45. #define call86(farfunc) ( _PC = (farfunc), caller() )
  46. #define int86(inum) ( call86( isr_get_vec( (inum) ) ) )
  47. #define pcdos(func) ( _AH = (func), int86(0x21) )
  48.  
  49.  
  50.